﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bovril.SmallWorld.Core
{
    internal class BoardRegion : IBoardRegion
    {
        internal BoardRegion(String name, Terrain.Type terrain, bool isAtEdge)
        {
            Terrain = terrain;
            IsAtEdge = isAtEdge;

            name_ = name;
            adjacentRegions_ = new List<BoardRegion>();
        }

        public override String ToString()
        {
            return String.Format("{0} ; {1} ; {2} adjacent tiles", name_, Terrain.ToString(), adjacentRegions_.Count);
        }

        public Terrain.Type Terrain { get; private set; }
        public bool IsAtEdge { get; private set; }

        internal void AddAdjacentRegion(BoardRegion region)
        {
            if (adjacentRegions_.Contains(region))
                throw new ArgumentException("region", "attempt to add the same region a second time");

            adjacentRegions_.Add(region);
        }

        private String name_;
        private List<BoardRegion> adjacentRegions_;
    }
}
